package com.hang.ad.controller;

import com.hang.ad.entity.AdPlan;
import com.hang.ad.exceptions.AdException;
import com.hang.ad.service.IAdPlanService;
import com.hang.ad.vo.AdPlanGetRequest;
import com.hang.ad.vo.AdPlanRequest;
import com.hang.ad.vo.AdPlanResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
public class AdPlanController {
    @Autowired
    private IAdPlanService adPlanServiceImpl;

    @PostMapping("/create/plan")
    public AdPlanResponse createAdPlan(@RequestBody AdPlanRequest request) throws AdException {
        return adPlanServiceImpl.createAdPlan(request);
    }

    @PostMapping("/get/plan")
    public List<AdPlan> getAdPlan(@RequestBody AdPlanGetRequest request) throws AdException{
        return adPlanServiceImpl.getAdPlanByIds(request);
    }

    @PutMapping("/update/plan")
    public AdPlanResponse updateAdPlan(@RequestBody AdPlanRequest request) throws AdException{
        return adPlanServiceImpl.updateAdPlan(request);
    }

    @DeleteMapping("delete/plan")
    public void deleteAdPlan(@RequestBody AdPlanRequest request) throws AdException{
        adPlanServiceImpl.deleteAdPlan(request);
    }

}
